<?php
	require '../conn.php';
        require_once '../libs/global.cls';
        
	$username = $_POST['username'];
        $apass = str_replace(" ","",$_POST['password']);
        $pwd = md5($apass);

        // 账号为空
        if(empty ($username)){
            $error_type = 201;
            include_once '../error/login_error.php';
            exit;
        }

        // 登录
        $regemail = "^([a-za-z0-9_-])+@([a-za-z0-9_-])+(\.[a-za-z0-9_-])";
        if(ereg($regemail, $username)){
            // 使用email地址登录
            $sql = "select * from cc_user where emai='".$username."' and password='".$pwd."'";
        }
        else{
            // 使用cc号登录
            $sql = "select * from cc_user where cc_id='".$username."' and password='".$pwd."'";
        }
        $res = $ms_cc_pdo->select($sql);
        $row = $res['result'];
        if(count($row)){
            redirect("../index.php?cid=".$row[0]['cc_id']);
        }  else {
            $error_type = 203;
            include_once '../error/login_error.php';
            exit;
        }
?>

